import LineFromChoose from '@/components/LineFromChoose/'

export default {
  components: {
    LineFromChoose
  },
  data() {
    return {
      ChartColors: ['#c23531', '#2f4554', '#61a0a8',
        '#d48265', '#91c7ae', '#749f83',
        '#ca8622', '#bda29a', '#6e7074',
        '#546570', '#c4ccd3'],
      chartExtend: {
        series(v) {
          v.forEach(i => {
            i.barWidth = 15
          })
          return v
        },
        tooltip(v) {
          v.trigger = 'none'
          return v
        }
      }
    }
  },
  methods: {
    pie(chartData, key_mapper) {
      const RegObj = {}
      let RegStr = ''
      key_mapper.forEach(item => {
        RegObj[item.key] = item.name
        RegStr = RegStr + item.key + '|'
      })
      const Reg = new RegExp(`${RegStr}`, 'g')
      const strChartData = JSON.stringify(chartData)
      const newstrChartData = strChartData.replace(Reg, function(match) {
        return RegObj[match] || match
      })
      return JSON.parse(newstrChartData)
    }
  }
}
